using UnityEngine;
using System.Collections;

public class Click : MonoBehaviour {
	
	public bool vazio = true;
	
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (Input.GetButtonDown("Fire1")) 
		{
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			RaycastHit hit;
			Vector3 posicao;
			
			if(collider.Raycast(ray,out hit,Mathf.Infinity))
			{
				if(vazio && (TelaGUI.torreAtual != null))
				{
					posicao.y = TelaGUI.torreAtual.transform.position.y;
					posicao.x = transform.position.x;
					posicao.z = transform.position.z;
					
					TelaGUI.torreAtual.transform.position = posicao;
					Destroy(TelaGUI.torreAtual.GetComponent<Arrastar>());
					vazio = false;
					TelaGUI.torreAtual = null;
				}
			}
		}
	}
}
